<!--#include file="MenuDb.asp"-->
<!--#include file="IncMenu.asp" -->
<%
If request("fatherID")<>"" then
fatherID=int(request("fatherID"))
Else
fatherID=0
End if
%>
<TABLE  id='TableMain' border='1' align='center' cellPadding='1' cellSpacing='1' style="BORDER: #cccccc 0px solid;">
<form method="post" action="?Action=Add">
<tr>
<td>
<select name="fatherID">
<option value="0">0.顶级菜单</option>
<%
sql="select * from Nav_Menu where fatherID=0 order by paixu"
Rs.open sql,conn,1,1
for m=1 to rs.recordcount
%>
<option value='<%=int(Rs("ID"))%>' <%If fatherID=int(Rs("ID")) then%>selected<%End if%>><%=int(Rs("paixu"))%>.<%=rs("name")%></option>
<%
rs.moveNext
Next
rs.close
%>
</select>
Name<input type="text" name="name" >
URL<input type="text" name="url"  value="" size='40'>
Target
<select name="URLTarget">
<option value="FrmMain">FrmMain</option>
<option value="_blank">_blank</option>
<option value="_self">_self</option>
</select>
<input type="text" name="Comment" value="说明">
<select name="isshow">
    <option value="1" selected>显示</option>
	<option value="0">不显示</option>
</select>
排序<input type="text" name="paixu" value="10" size='3'>
<input type="submit" name="Submit" value="添加">
</td>
</tr>
</form>
</table>
<BR>
<!-- List -->
<TABLE  id='TableMain' border='0' align='center' cellPadding='2' cellSpacing='1' style="BORDER: #cccccc 0px solid;">
<TR>
	<TD width='200' valign='top' style="BORDER: #ddeeff 1px solid;" bgcolor='#ddeeff'>

<!-- 显示全部父级分类 ------------------------>
<TABLE width='100%' border='0' align='center' cellPadding='2' cellSpacing='1' >
<tr>
<TD style="BORDER-bottom: #cccccc 1px solid;">
<img src="Icon/folderopen.gif" border="0" alt=""><a href="?fatherID=0"><b>0.全部分类</b></a>
</td>
</tr>
<%
sql="select * from Nav_Menu where fatherID=0 order by paixu"
rs.open sql,Conn,1,1
for m=1 to rs.recordcount
%>
<tr <%If fatherID=int(Rs("ID")) Then %>bgcolor='#ccff66' <%else%><%End if%>>
<TD style="BORDER-bottom: #cccccc 1px solid;" >
<img src="Icon/folderopen.gif" border="0" alt=""><a href="?fatherID=<%=int(rs("ID"))%>"><b><%=trim(rs("paixu"))%>.<%=Trim(rs("name"))%></b></a>
</td>
</tr>
<%
rs.moveNext
Next
rs.close
%>
</table>

</TD>
<!-- 显示选择的父级分类 ***************************************-->
<TD valign='top' >
<u><strong>删除说明:删除一级类,其所属二级类也一并删除;删除的数据不提供恢复操作.</strong></u>
<TABLE width='100%' border='0' align='center' cellPadding='2' cellSpacing='1' style="BORDER: #cccccc 0px solid;">
<tr bgcolor="#ddeeff">
<TD >ID/paixu</TD>
<TD >Edit</TD>
<TD >Name</TD>
<TD >URL/Target</TD>
<TD >Comment</TD>
<TD >IsShow</TD>
<TD >Del</TD>
</TR>
<%
'sql="select * from Nav_Menu where FatherID=0 order by paixu"
If fatherID=0 then
sql="select * from Nav_Menu where fatherID="&fatherID&" order by paixu"
else
sql="select * from Nav_Menu where ID="&fatherID&" order by paixu"
End if
rs.open sql,conn,1,1
For iPage = 1 To rs.recordcount
%>
<tr style="cursor:hand" onmouseover="this.bgColor='#CCFF99';" onmouseout="this.bgColor='#CCFFCC';" bgcolor='#CCFFCC' >
<TD style="BORDER-bottom: #CCCCCC 1px solid;" width='20'><img src="Icon/book.gif" alt="<%=rs("id")%>,<%=rs("Fatherid")%>"  border='0' /><%=rs("paixu")%></TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><A HREF="MenuEdit.asp?EditMenuID=<%=int(rs("id"))%>">修改</A></TD>
<td  style="BORDER-bottom: #CCCCCC 1px solid;"><B><%=Trim(rs("name"))%></B></TD>
<td  style="BORDER-bottom: #CCCCCC 1px solid;"><font  color="#FF0000"><i><%=left(Trim(rs("URL")),50)%></i></font>[<%=rs("URLTarget")%>]</TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><%=Trim(rs("comment"))%>&nbsp;</TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><a href="?EditMenuID=<%=int(rs("id"))%>&Action=ShowMod"><%If Int(rs("isshow"))=0 then%>不显示<%else%><font color="#FF0000">在显示</font><%End if%></a></TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><a href="?EditMenuID=<%=int(rs("id"))%>&Action=Del" title='删除一级类,其所属二级类也一并删除'>删除</a></TD>
</tr>
<%
sqls="select * from Nav_Menu where FatherID="&Trim(rs("id"))&" order by paixu"
rss.open sqls,conn,1,1
for r_s=1 to rss.recordcount
ID=int(rss("id"))
%>
<tr style="cursor:hand" onmouseover="this.bgColor='#ddeeff';" onmouseout="this.bgColor='#ffffff';">
<TD style="BORDER-bottom: #CCCCCC 1px solid;">&nbsp;<img src="Icon/bookopen.gif" border='0' /><%=rss("paixu")%></TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><A HREF="MenuEdit.asp?EditMenuID=<%=ID%>" title='<%=Trim(rss("name"))%>'>修改</A></TD>
<td  style="BORDER-bottom: #CCCCCC 1px solid;"><B><%=Trim(rss("name"))%></B></TD>
<td  style="BORDER-bottom: #CCCCCC 1px solid;"><a href="<%=Trim(rss("URL"))%>" target='_blank'><font  color="#FF0000"><i><%=left(Trim(rss("URL")),50)%></i></font></a>&nbsp;[<%=rss("URLTarget")%>]</TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><%=Trim(rss("Comment"))%>&nbsp;</TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><a href="?EditMenuID=<%=ID%>&Action=ShowMod"><%If Int(rss("isshow"))=0 then%>不显示<%else%><font color="#FF0000">在显示</font><%End if%></A></TD>
<TD style="BORDER-bottom: #CCCCCC 1px solid;"><a href="?EditMenuID=<%=ID%>&Action=Del">删除</A></TD>
</tr>


<%
rss.moveNext
Next
rss.close

rs.MoveNext
Next
rs.close
%>
</Table>

</TD>
</TR>
</TABLE>
<%
'SQL Precess
Action=request("Action")
'Add New Record
If Action="Add" then
sql= "SELECT * FROM Nav_Menu WHERE (id is null)"
rs.open sql,conn,1,3
rs.addnew
rs("name") =Trim(Request("name"))
rs("url") =Trim(Request("url"))
rs("fatherID") =CInt(Request("fatherID"))
rs("urltarget") =Trim(Request("urltarget"))
rs("comment") =Trim(Request("comment"))
rs("isshow") =Trim(Request("isshow"))
rs("paixu") =Trim(Request("paixu"))
rs.Update
rs.close
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'Modify Record
If Action="Mod" Then
EditMenuID=Int(request("EditMenuID"))
sql= "SELECT * FROM Nav_Menu WHERE id="&EditMenuID
rs.open sql,conn,1,3
rs("name") =Trim(Request("name"))
rs("url") =Trim(Request("url"))
rs("fatherID") =CInt(Request("fatherID"))
rs("urltarget") =Trim(Request("urltarget"))
rs("comment") =Trim(Request("comment"))
rs("isshow") =Trim(Request("isshow"))
rs("paixu") =Trim(Request("paixu"))
rs.Update
rs.close
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

'ShowMod Record
If Action="ShowMod" Then
EditMenuID=Int(request("EditMenuID"))
sql= "UPDATE Nav_Menu SET IsShow=1-IsShow WHERE id="&EditMenuID
conn.execute (sql)
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "GuideMenuAdmin.asp"
End If

'Delete Record
If Action="Del" Then
EditMenuID=Int(request("EditMenuID"))
'删除自身
conn.execute ("delete FROM Nav_Menu WHERE id="&EditMenuID&" ")
'删除父级以及其子类
conn.execute ("delete FROM Nav_Menu WHERE Fatherid="&EditMenuID&" ")
set conn=nothing
response.redirect Request.ServerVariables("Http_referer")
'response.redirect "menuadmin.asp"
End If

%>

<!--#include file="foot.asp" -->